package solution;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2023-01-17
 * Time: 23:13
 */
public class Solution8 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3};
        System.out.println(arraySum(arr, arr.length));
    }
    public static int arraySum(int[] array,int len) {
        return len == 1 ? array[0] : array[len - 1] + arraySum(array, len - 1);
    }
}
